package cate.common.table.item.spice.row;

import cate.common.table.EExcelNoteField;
import cate.common.table.EExcelRowClass;
import cate.common.table.ERow;
import cate.common.table.item.IBagItemTpl;
import cp.solution.util.str.Str;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@EExcelRowClass
public class SpiceBaseRow extends ERow implements IBagItemTpl {
    @EExcelNoteField(fieldName = "名称")
    public String name;

    @EExcelNoteField(fieldName = "品质")
    public int quality;

    @EExcelNoteField(fieldName = "类型")
    public byte type;

    @EExcelNoteField(fieldName = "原型ID")
    public int protoId;

    @EExcelNoteField(fieldName = "基础经验")
    public int baseExp;

    @EExcelNoteField(fieldName = "栏位ID")
    private String posStr;

    public List<Byte> posList = new ArrayList<>();

    @Override
    public void decode() {
        if (StringUtils.isNotBlank(posStr)) {
            posList.addAll(Objects.requireNonNull(Str.str2ByteList(posStr, "#")));
        }
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public String toName() {
        return this.name;
    }

    @Override
    public boolean unique() {
        return type != 0;
    }

    @Override
    public int getTemplateId() {
        return id;
    }

    @Override
    public long getPileMax() {
        return 1;
    }
}
